<template>
	<view class="container">
		<view class="AvatarBody">
			<view class="AvatarImgBg">
				<image class="AvatarImg" :src="AvatarImg"></image>
			</view>
		</view>

		<view class="StuMsgBg">
			<view class="StuMsgTitleBg">
				<text class="StuMsgTitle" @click="CheckInfo()">
					<template >{{ChenckInfo}}</template>
					</text>
			</view>
			<view class="StuMsgBody">
				<text class="StuMsgAttr">姓名：<text>{{(IsChenck)?Student.name:"*"}}</text>
				</text>
				<text class="StuMsgAttr">系部：<text>{{(IsChenck)?Student.departmentName:"*"}}</text></text>
				<text class="StuMsgAttr">学号：<text>{{(IsChenck)?Student.studentNo:"*"}}</text></text>
				<text class="StuMsgAttr">专业：<text>{{(IsChenck)?Student.majorName:"*"}}</text></text>
				<text class="StuMsgAttr">宿舍：<text>{{(IsChenck)?Student.buildName:"*"}}</text></text>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				AvatarImg: "../../static/icon/PersonCenter.png",
				IsChenck: false,
				ChenckInfo:"查看个人信息",
				Student: "",
			}
		},
		onLoad() {
			this.getStudentData();
		},
		methods: {
			// 获取页面数据
			getStudentData() {
				let _Student = this.Student;
				// $httpUrl在项目目录修改main.js
				let loginToken = uni.getStorageSync('login');
				console.log(loginToken);
				var studentId = loginToken.id;
				uni.request({
					url: this.$httpUrl + '/QrCodeProc/GetStudentDetail',
					method: 'POST',
					header: {
						'Content-Type': 'application/x-www-form-urlencoded',
					},
					data: {
						studentId: loginToken.id
					},
					success: success => {
						console.log("获取学生详情返回数据1", success);
						uni.showToast({
							title: '获取成功'
						})
						_Student = success.data.data;
						if(_Student.photoPath!=null){
							//console.log("获取学生地址",this.$httpUrl);
							this.AvatarImg=this.$httpUrl+"/images/avatars/"+_Student.photoPath;
							//console.log("获取学生照片", this.AvatarImg);
						}
						this.Student = _Student;
						//console.log("获取学生详情返回数据2", _Student);
					},
					fail: (fail) => {
						console.log(fail);
					}
				})
			},
			CheckInfo() {
				if(this.IsChenck){
					this.IsChenck=false,
					this.ChenckInfo="查看个人信息"
				}else{
					this.IsChenck=true;
					this.ChenckInfo="隐藏个人信息"}
				console.log(this.IsChenck);
			}
		},
	}
</script>

<style>
	.container {
		text-align: left;
	}

	.AvatarBody {
		height: 20vh;
		width: 40vw;
		margin: 1vh auto;
	}

	.AvatarImgBg {
		height: 20vh;
		width: 40vw;
		box-shadow: 2rpx 2rpx 10rpx #007AFF;
		/* background-color: #007AFF; */
		border: 5rpx solid #007AFF;
		border-radius: 100%;
		overflow: hidden;
	}

	.AvatarImg {
		height: 100%;
		width: 100%;
	}

	.StuMsgBg {
		position: absolute;
		line-height: 8vh;
		height: auto;
		width: 90vw;
		left: 5vw;
		top: 22vh;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		box-shadow: 2rpx 2rpx 10rpx #27347d;
	}


	.StuMsgTitle {
		display: block;
		color: white;
		background: #fdbb59;
		padding: 0.2rem;
		font-size: 0.7rem;
		height: 5vh;
		line-height: 5vh;
		width: 20vw;
		border-radius: 1vw;
		margin: 1vh auto;
		box-shadow: 2rpx 2rpx 10rpx #d49b4b;
	}

	.StuMsgBody {}

	.StuMsgAttr {
		margin-left: 10vw;
		float: left;
		width: 70vw;
		height: 7vh;
	}
</style>
